// Created by Joe on 2017/7/20.

// REGION
var JINAN = {
    cityCode: '370100',
    cityName: '济南',
    stationID: '54823',
    region: [
        {regionName: '市辖区', regionCode: '370101'},
        {regionName: '历下区', regionCode: '370102'},
        {regionName: '市中区', regionCode: '370103'},
        {regionName: '槐荫区', regionCode: '370104'},
        {regionName: '天桥区', regionCode: '370105'},
        {regionName: '历城区', regionCode: '370112'},
        {regionName: '长清区', regionCode: '370113'},
        {regionName: '平阴县', regionCode: '370124'},
        {regionName: '济阳县', regionCode: '370125'},
        {regionName: '商河县', regionCode: '370126'},
        {regionName: '章丘市', regionCode: '370181'}
    ]
};

var QINGDAO = {
    cityCode: '青岛市',
    cityName: '370200',
    stationID: '54857',
    region: []
};

var ZIBO = {
    cityCode: '370300',
    cityName: '淄博市',
    stationID: '54830',
    region: []
};

var ZAOZHUANG = {
    cityCode: '370400',
    cityName: '枣庄市',
    stationID: '58024',
    region: []
};

var DONGYING = {
    cityCode: '370500',
    cityName: '东营市',
    stationID: '54736',
    region: []
};

var YANTAI = {
    cityCode: '370600',
    cityName: '烟台市',
    stationID: '54765',
    region: []
};

var WEIFANG = {
    cityCode: '370700',
    cityName: '潍坊市',
    stationID: '54843',
    region: []
};

var JINING = {
    cityCode: '370800',
    cityName: '济宁市',
    stationID: '54915',
    region: []
};

var TAIAN = {
    cityCode: '370900',
    cityName: '泰安市',
    stationID: '54827',
    region: []
};

var WEIHAI = {
    cityCode: '371000',
    cityName: '威海市',
    stationID: '54774',
    region: []
};

var RIZHAO = {
    cityCode: '371100',
    cityName: '日照市',
    stationID: '54945',
    region: []
};

var LAIWU = {
    cityCode: '371200',
    cityName: '莱芜市',
    stationID: '54828',
    region: []
};

var LINYI = {
    cityCode: '371300',
    cityName: '临沂市',
    stationID: '54938',
    region: []
};

var DEZHOU = {
    cityCode: '371400',
    cityName: '德州市',
    stationID: '54714',
    region: []
};

var LIAOCHENG = {
    cityCode: '371500',
    cityName: '聊城市',
    stationID: '54806',
    region: []
};

var BINZHOU = {
    cityCode: '371600',
    cityName: '滨州市',
    stationID: '54734',
    region: []
};

var HEZE = {
    cityCode: '371700',
    cityName: '菏泽市',
    stationID: '54906',
    region: []
};

// REGION_MAP
var REGION_MAP = [
    {name: JINAN, scope: [4096, 4106]},
    {name: QINGDAO, scope: [4353, 4364]},
    {name: ZIBO, scope: [4608, 4616]},
    {name: ZAOZHUANG, scope: [4864, 4870]},
    {name: DONGYING, scope: [5120, 5125]},
    {name: YANTAI, scope: [5376, 5388]},
    {name: WEIFANG, scope: [5632, 5644]},
    {name: JINING, scope: [5888, 5900]},
    {name: TAIAN, scope: [6144, 6150]},
    {name: WEIHAI, scope: [6400, 6404]},
    {name: RIZHAO, scope: [6656, 6660]},
    {name: LAIWU, scope: [6912, 6914]},
    {name: LINYI, scope: [7168, 7180]},
    {name: DEZHOU, scope: [7424, 7435]},
    {name: LIAOCHENG, scope: [7680, 7688]},
    {name: BINZHOU, scope: [7936, 7943]},
    {name: HEZE, scope: [8192, 8201]}
];

// assist function
function getCurCity(regionID) {
    regionID = regionID || 4096;

    var curCity = REGION_MAP.filter(function (item) {
        return regionID >= item.scope[0] && regionID <= item.scope[1];
    });

    return curCity[0]['name'];
}

// console.log(getCurCity(4099));
// console.log(getCurCity(8201));